
	var ts01 = (function() {
		var ts01 = {};
		
		ts01.cancel = function(id){
			var userId = $("#_leo_user_id").val();
			$.post(suffix + '/tools/cancel',{
				"id":id
			}).always(
					function(data) {
						if(data.code == 0){
							alert("取消预约成功");
						}else{
							alert("操作失败");
						}
						window.location.href = "tools.html?userId=" + userId;								
						}, "json").fail(function() {
				alert("fail！");
				return;
			});
			
		}
		//todo
		ts01.makeTools =function(id){
			var userId = $("#_leo_user_id").val();
			$.confirm({
		        title: '确认预约',
		        content: '您是否需要进行预约?',
		        buttons: {
		            ok: {
		                text: '确认',
		                btnClass: 'btn-primary',
		                action: function() {
		                	var data =  {
		        					"id":id,
		        					"userId":userId
		        				};
		        			$.post(suffix + '/tools/makeTools',data).always(
		        					function(data) {
		        						if(data.code == 0){
		        							alert("预约成功");
		        						}else{
		        							alert("操作失败");
		        						}
		        						
		        						window.location.href = "tools.html?userId=" + userId;								
		        						}, "json").fail(function() {
		        				alert("fail！");
		        				return;
		        			});
		                }
		            },
		            cancel: {
		                text: '取消',
		                btnClass: 'btn-primary'
		            }
		        }
		    });
		};
		
		var suffix = "/leo";
		return ts01;
	})(jQuery);

